/**
 * BudgetBuoy
 * 
 * Simplify your personal expense management
 * 
 * @team cs2103jan13-w15-3j
 */

//--------------------------------------------------------------

/**
 * Record Class
 * 
 * Description: Getters and Setters for Record Object
 * 
 * 
 * @package shared
 * @author Li Yin (A0085686L)
 * @editor(s) -
 */


package shared;

public abstract class Record implements Comparable<Record> {
	protected int ID;
	protected String name;
	//date
	protected int yy;
	protected int mm;
	protected int dd;
	protected int amt;
	protected String detail;

	//getters
	public int getID(){
		return ID;
	}
	public String getName(){
		return name;
	}
	
	public int getYear(){
		return yy;
	}
	public int getMonth(){
		return mm;
	}
	public int getDay(){
		return dd;
	}
	public int getAmt(){
		return amt;
	}
	public String getDetail(){
		return detail;
	}

	//mutators
	public void modifyName(String newName){
		name=newName;
	}
	public void modifyYear(int newyy){
		yy=newyy;
	}
	public void modifyMonth(int newmm){
		mm=newmm;
	}
	public void modifyDay(int newdd){
		dd=newdd;
	}
	public void modifyAmt(int newAmt){
		amt=newAmt;
	}
	public void modifyDetail(String newDetail){
		detail=newDetail;
	}

	//comparator
	@Override
	public int compareTo(Record o) {
		return ID-o.getID();
	}

	//toString edited by siling
	@Override
	public String toString(){
		
		String nameSegment = name + "                    ";
		nameSegment = nameSegment.substring(0,20); //limit name to 20 characters
		
		String[] process = this.getClass().toString().split("\\.");
		String typeSegment = process[process.length-1]+  "                    ";
		typeSegment = typeSegment.substring(0, 20);
		
		String dateSegment = String.format("%2d", dd) + "." + String.format("%2d", mm) + "." + String.format("%4d", yy) + "              ";
		dateSegment.substring(0, 15);
		String amountSegment = String.format("$%9.2f", (double)amt/100.00);  
		return  nameSegment + dateSegment + typeSegment + amountSegment; 
		
	}
}
